import {hrAjax as proFetch} from 'src/hrpub/common/utils/utils';
import updateButtonStatus from "./updateButtonStatus";
import {toast} from 'nc-lightapp-front';

export default function getMainTableData(isRefresh) {
    const {orgVal, searchModalValue, queryOid} = this.state;

    return proFetch({
        url: '/nccloud/hrcm/contopinion/OpinionRemcQueryAction.do',
        body: {
            querycondition: searchModalValue,
            querytype: 'tree',
            oid: queryOid,
            pk_org: orgVal.refpk
        },
    }).then((res) => {
        if (res.success) {
            if (isRefresh) {
                toast({color: "success", content: this.state.json['cm6011-000099']});
            }
            if (res.data && res.data.contopiniongrid) {
                this.props.editTable.setTableData('contopiniongrid', {rows: res.data.contopiniongrid.rows});
            } else {
                this.props.editTable.setTableData('contopiniongrid', {rows: []});
            }
            updateButtonStatus.call(this, this.state.orgVal);
        }
    });
}
